package com.example.chat.aspect;


import com.example.chat.utils.RedisConstants;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Aspect
@Component
@Slf4j
public class PvCount {

//    @Resource
//    private StringRedisTemplate stringRedisTemplate;

    @Pointcut("execution(* com.example.chat.controller.*.*(..))")
    public void pt(){}

    @Before("pt()")
    public void before(){
//        log.info("PV统计执行......");
//        LocalDateTime now = LocalDateTime.now();
//        StringBuilder builder = new StringBuilder();
//        String dateKey = builder.append("admin:").append(now.getYear()).append(":")
//                .append(now.getMonthValue()).append(":")
//                .append(now.getDayOfMonth()).append(":PV").toString();
//        stringRedisTemplate.opsForValue().increment(dateKey);
//        String pvCount = stringRedisTemplate.opsForValue().get(dateKey);
    }
}
